package plugin

import (
	"Ahq/Models"
	"Ahq/ValiEngine"
)

type PositiveCalculation struct {
}

func (r *PositiveCalculation) GetName() string {
	return "正数计算"
}
func (r *PositiveCalculation) GetDesc() string {
	return "每一步计算都是正数"
}

func (r *PositiveCalculation) GetKey() string {
	return "PositiveCalculation"
}
func (r *PositiveCalculation) GetShow() bool {
	return true
}

func (r *PositiveCalculation) Vali(operator byte, operand1 int, operand2 int) bool {

	if operand1 < 0 || operand2 < 0 {
		return false
	}

	if operator == Models.Subtraction && operand1 < operand2 {
		return false
	}
	return true
}

func init() {
	ValiEngine.RegisterRule("PositiveCalculation", new(PositiveCalculation))
}
